<?php 


require "../common/Curl.php";

/**
 *	https://open.esign.cn/doc/detail?id=opendoc%2Fidentity_service%2Feaug1b&namespace=opendoc%2Fidentity_service
 * 	e签宝 认证服务API
 * 	个人认证 认证服务网页版----接口顺序排列封装
 *  使用请求签名鉴权方式
 *  下一个------------------ 认证服务纯API版 authpersonapi.php
 */



//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

/**
 * [authPerson 获取个人实名认证地址]
 * @param  [type] $aaaa      [其他参数]
 * @param  [type] $accountId [个人账号id]
 * @return [json]            [返回短链接长链接]
 */
function authPersonName($aaaa,$accountId,$appId,$secret,$url){
	$urlss = $url."/v2/identity/auth/web/".$accountId."/indivIdentityUrl";
	$head_url = "/v2/identity/auth/web/".$accountId."/indivIdentityUrl";
    $data = json_decode($aaaa,true);
    $res = json_encode($data);
    $header = getHeader($data,"POST",$head_url,$appId,$secret,$url);
    $result = sendHttp($method="POST",$urlss,$header,$res);
    return $result;
}
// $accountId = "9e053884172641a5a464d80fb9dae6c7";
// $aaaa = '{
//     "authType": "PSN_BANK4_AUTHCODE",
//     "availableAuthTypes":["PSN_TELECOM_AUTHCODE","PSN_BANK4_AUTHCODE","PSN_FACEAUTH_BYURL"],
//   	"authAdvancedEnabled":["PSN_BANK4_AUTHCODE","PSN_TELECOM_AUTHCODE"],
//     "contextInfo": {
//         "contextId": "57cc9602-d1b6-48bd-bdbb-61e9f8443955",
//         "notifyUrl": "https://www.notifyUrl.cn",
//         "origin": "BROWSER",
//         "redirectUrl": "https://www.redirectUrl.cn",
//         "showResultPage": true
//     },
//     "indivInfo": {
//         "name": "刘颂晶",
//         "certType": "INDIVIDUAL_CH_IDCARD",
//         "certNo": "360731199907050379",
//         "mobileNo": "15179798856",
//         "bankCardNo": "6227123412341234123"
//     },
//     "configParams": {
//         "indivUneditableInfo": ["name", "certNo", "mobileNo", "bankCardNo"]
//     },
//     "repeatIdentity": true
// }';
// $a = authPersonName($aaaa,$accountId,$appId,$secret,$url);
// var_dump($a);die;

// "{"code":0,"message":"成功","data":{"url":"https://smlfront.esign.cn:8890/identity/login?appId=7438873193¶m=xUnzL%2FYfvX%2BjAqapS0uBVXvQwSHdwVMRB2newrVw7R%2F7FkVlFOfgMh2KKOY32h8e0drxMuW1GrZSV4vrahAlWGCI%2BGT4tBdT14gGQ3mkVaakvSPejdqtwZYWqA%2F4LkHzW7NePjrRq1pJ3yOMPIhLZnQJdmlzk%2FihBvFIWynfPqqhkM1YNWk8iIZ9PTH17h7L0rThYo6ow%2FJFAJZIaINcD0bNtM2Y3iiF6LPBG%2FsD%2Bvz%2BAkg37o1GYAT4zlKb%2BoTO5AvN02hvPSgoCAF5RmMjc6cXxcsAUcyZ8o3TOE%2F2RBIs7gxogvxOzZTBN1PbfX0Gy5YWn6BwMi7FsL4DMa%2BG%2FNaSLm9eu0ZqqkCoH2%2FfeGN1TPOgELYq39t1n80KiTVdQKHs9RJuiU05FE9DcpKTJ5PZLgSy9hEnEFpo8VqrArZ7XBbU4aBHkH5lG0PBJEyD&lang=zh-CN","shortLink":"https://smlt.esign.cn/atVhbXmyM6La","flowId":"1941593621355037775"}}"

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

/**
 * [authPersonBody 获取个人核身认证地址]
 * @param  [type] $aaaa   [description]
 * @return [json]         [返回结果]
 */
function authPersonBody($aaaa,$appId,$secret,$url){
	$urlss = $url."/v2/identity/auth/web/indivAuthUrl";
	$head_url = "/v2/identity/auth/web/indivAuthUrl";
    $data = json_decode($aaaa,true);
    $res = json_encode($data);
    $header = getHeader($data,"POST",$head_url,$appId,$secret,$url);
    $result = sendHttp($method="POST",$urlss,$header,$res);
    return $result;
}
// $aaaa = '{
//     "authType": "PSN_BANK4_AUTHCODE",
//     "availableAuthTypes":["PSN_TELECOM_AUTHCODE","PSN_BANK4_AUTHCODE","PSN_FACEAUTH_BYURL"],
//   	"authAdvancedEnabled":["PSN_BANK4_AUTHCODE","PSN_TELECOM_AUTHCODE"],
//     "contextInfo": {
//         "contextId": "993de698a82b43d9ba6a4fb26093629e",
//         "notifyUrl": "http://172.20.62.10:8080/testnotify/msgRecive",
//         "redirectUrl": "https://www.esign.cn/aboutUs/join_us.html",
//         "showResultPage": true
//     },
//     "indivInfo": {
//         "name": "刘颂晶",
//         "certNo":"360731199907050379"
//     },
//     "configParams": {
//         "indivUneditableInfo": ["name", "certNo", "mobileNo", "bankCardNo"]
//     }
// }';
// $a = authPersonBody($aaaa,$appId,$secret,$url);
// var_dump($a);die;




